package top.infopub.util;


import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;


/**
 * emoji拦截
 * @author Awoke
 * @version 2015-12-24
 * @see EmojiFilterUtil
 * @since
 */
public final class EmojiFilterUtil {

    /**
     * 替换emoji表情
     * @param source
     * @return 
     * @see
     */
    public static String escape(String source) {
        if (StringUtils.isBlank(source)) {
            return source;
        }

        return Pattern.compile(
            "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
            Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE).matcher(source).replaceAll("");
    }

    /**
     * test
     * @param args 
     * @see 
     */
    public static void main(String[] args) {
        String source = "{'id':'2','value':'222'}\ud83c\udc00\ud83c\udc00";
        System.out.println(escape(source));
        System.out.println("\ue048" + " hello emoji...");
    }

}
